<?php

include "config.php";

if($_SERVER["REQUEST_METHOD"]=="POST"){
    session_start();//开启session
    if(isset($_POST["uname"])&&isset($_POST["upwd"])&&mb_strlen($_POST["uname"])>0&&mb_strlen($_POST["upwd"])>0){
        $UNAME=$_POST["uname"];
        $UPWD=$_POST["upwd"];
        $sqlLogin="SELECT * FROM userinfo WHERE u_name='" . $UNAME . "' AND u_pwd='" . $UPWD . "';";
        $result=$connection->query($sqlLogin);
        if($result->num_rows>=1){
            $_SESSION["userinfo"]=$result->fetch_assoc();
            print_r(json_encode(array("status"=>1,"mas"=>"登陆成功")));
        }else{
            print_r(json_encode(array("status"=>-1,"mas"=>"登陆失败")));
        }
        $connection->close();

    }
    else{
        print_r(json_encode(array("status"=>-2,"mas"=>"账号密码不能为空")));
    }
}else{
    print_r(json_encode(array("status"=>0,"mas"=>"不支持GET请求")));
}